<?php 

class CommentGroup {
	private $Items = array();
	private $Controller;
	
	private $ApplicationOwner;
	private $ApplicationEntryID;
	
	function __construct($app, $app_entry, CommentController $Controller, $offset = 0, $limit = 10){
		$this->Controller = $Controller;
		$this->ApplicationOwner = $app;
		$this->ApplicationEntryID = $app_entry; 
		
		$MySQL = $Controller->UseApps["mysql"];
		
		$CommentGroupItems = $MySQL->query("SELECT * FROM {$MySQL->getPrefix()}comment WHERE application_owner = '$app' AND application_entry_id = $app_entry ORDER BY date_time ASC LIMIT $offset, $limit");

		if(mysql_num_rows($CommentGroupItems) <= 0){
			return false;
		}
		
		while($CommentItem = mysql_fetch_assoc($CommentGroupItems)){
			$this->Items[] = new Comment($CommentItem["id"], $this->Controller);
		}		
	}
	
	function getItems(){
		if(count($this->Items) == 0){
			return false;
		}
		
		return $this->Items;
	}
	
	function getApplicationOwner(){
		return $this->ApplicationOwner;
	}
	
	function getApplicationEntryID(){
		return $this->ApplicationEntryID;
	}
}

?>